﻿using MES.Desktop.Common;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MES.Desktop.BasicDataModule.Models
{
    public class MaterialClassModel : DataModelBase
    {
        public int ItemTypeId { get; set; }
        public string ItemTypeCode { get; set; }
        public string ItemTypeName { get; set; }
        public int ParentTypeId { get; set; }
        public string Ancestors { get; set; }
        public string ItemOrProduct { get; set; }
        public int OrderNum { get; set; }
        public bool EnableFlag { get; set; }
        public string Remark { get; set; }
        public string attr1 { get; set; }
        public string attr2 { get; set; }
        public int attr3 { get; set; }
        public int attr4 { get; set; }
        public string CreateBy { get; set; }
        public DateTime CreateTime { get; set; }
        public string UpdateBy { get; set; }
        public DateTime UpdateTime { get; set; }



        public bool IsLastChild { get; set; }
        private bool _isExpanded;
        // 是否展开节点
        public bool IsExpanded
        {
            get { return _isExpanded; }
            set { SetProperty(ref _isExpanded, value); }
        }
        // 子节点
        public ObservableCollection<MaterialClassModel> Children { get; set; } =
            new ObservableCollection<MaterialClassModel>();

        public MaterialClassModel Parent { get; set; }

        private bool _isSelected;

        public bool IsSelected
        {
            get { return _isSelected; }
            set
            {
                SetProperty<bool>(ref _isSelected, value);

                if (!value)
                    foreach (var item in Children)
                    {
                        item.IsSelected = value;
                    }
            }
        }
    }
}
